<?php
include_once('common/header.php');			
if(!isset($intAjax)) {
	$objUser		= Zend_Registry::get('objUser');
	if(!$objUser) {	
		Vfriend_Function::redirect(LINK_INDEX_404);
	}else {
		if($objUser->statuses != 1) {
			$strMessage	= $arrMessage[10];
			$strMessage	= str_replace('[strFullname]',$objUser->fullnamevn, $strMessage);
			Vfriend_Function::setMsg($strMessage);
			Vfriend_Function::redirect(LINK_BLOG);
		}
	}
	$intOwnerId	= $objUser->id;
}
$objBlog 		= new Blog();
$strValue		= '';
$strStart		= '';
$strEnd			= '';
$intTotal		= 0;
$intLimit		= BLOG_LIMIT;
$strTime		= $objRequest->getParam('stime', '');
$intPage		= $objRequest->getParam('page', 1);
$intOffset		= ($intPage - 1) * $intLimit;
if($strTime != '') {
	$arrTime 	= explode('-', $strTime);
	$intYear	= $arrTime[1];	
	$intMonth	= $arrTime[0];
	$intDay 	= Vfriend_Function::daysInMonth($intMonth, $intYear);
	$intMonth	= $intMonth < 10 ? ('0'.$intMonth) : $intMonth;
	$intDay		= $intDay < 10 ? ('0'.$intDay) : $intDay;
	$strStart	= $intYear . '-' . $intMonth . '-01';
	$strEnd	  	= $intYear . '-' . $intMonth . '-' . $intDay;	
}
$arrResult		= $objBlog->getAllByUser($intOwnerId, $strStart, $strEnd, $strValue, $intOffset, $intLimit, $intTotal);
$this->view->arrResult		= $arrResult;
$this->view->intOwnerId		= $intOwnerId;
if(!isset($intAjax)) {
	$this->view->arrSort	= $arrSort;	
	$this->view->strTime	= $strTime;
}
$this->view->intTotalPage	= ceil($intTotal / $intLimit);
$this->view->intPage 		= $intPage;
?>